#
# Specifics for the pistachio kernel API
#

#
# Read default and builddir-specific config files
#
# In these config files, we expect to find the definition of PISTACHIO_USER_BUILD_DIR
#
-include $(call select_from_repositories,etc/pistachio.conf)
-include $(BUILD_BASE_DIR)/etc/pistachio.conf

ifeq ($(PISTACHIO_USER_BUILD_DIR),)
$(error Could not find the definition of PISTACHIO_USER_BUILD_DIR in etc/pistachio.conf)
endif

#
# Convert path to absolute directory
#
# We call find to resolve the home directory from '~'
# and use realpath to replace '..' substrings.
#
absdir = $(realpath $(shell find $(1) -maxdepth 0 -type d))

#
# Pistachio headers
#
PISTACHIO_USER_BUILD_ABS_DIR = $(call absdir,$(PISTACHIO_USER_BUILD_DIR))
INC_DIR += $(PISTACHIO_USER_BUILD_ABS_DIR)/include
#INC_DIR += $(PISTACHIO_USER_BUILD_ABS_DIR)

#
# Pistachio-specific Genode headers
#
REP_INC_DIR += include/pistachio

#
# Pistachio-specific startup code
#
PRG_LIBS += startup

#
# Compiler and linker options
#
CC_OPT_NOSTDINC = -nostdinc
CXX_LINK_OPT   += -static -nostdlib -Wl,-nostdlib -L$(PISTACHIO_USER_BUILD_ABS_DIR)/lib
EXT_OBJECTS    += -ll4
EXT_OBJECTS     += $(shell $(CUSTOM_CXX_LIB) -print-file-name=libsupc++.a) \
                   $(shell $(CUSTOM_CXX_LIB) -print-file-name=libgcc_eh.a) \
                   $(shell $(CUSTOM_CXX_LIB) -print-libgcc-file-name)
